package com.zbj.homemade.mybatis.conf;

import com.zbj.homemade.mybatis.utils.SqlFill;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @program: principle
 * @description:
 * @author: Yinn
 * @create: 2019-01-11 15:43
 **/
public class MappedStatement {

    private String namespace;

    private String id;

    private Class<?> resultType;

    private Class<?> parameterType;

    private String sql;

    private SqlCommandType sqlCommandType;

    private Configuration configuration;

    public String fillParameter(Object[] params){

        if (params == null)
            throw new RuntimeException("参数为空!");

        return SqlFill.replace(sql,params);
    }


    public static void main(String[] args) {

        Object[] params = {"1","2"};

        String sql = "select * from table where id = #{id} and name = #{name} and #{qqq}";

        String back = SqlFill.replace(sql,params);

        System.out.println(back);

    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Class<?> getResultType() {
        return resultType;
    }

    public void setResultType(Class<?> resultType) {
        this.resultType = resultType;
    }

    public Class<?> getParameterType() {
        return parameterType;
    }

    public void setParameterType(Class<?> parameterType) {
        this.parameterType = parameterType;
    }

    public String getSql() {
        return sql;
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

    public Configuration getConfiguration() {
        return configuration;
    }

    public void setConfiguration(Configuration configuration) {
        this.configuration = configuration;
    }

    public String getNamespace() {
        return namespace;
    }

    public void setNamespace(String namespace) {
        this.namespace = namespace;
    }

    public SqlCommandType getSqlCommandType() {
        return sqlCommandType;
    }

    public void setSqlCommandType(SqlCommandType sqlCommandType) {
        this.sqlCommandType = sqlCommandType;
    }
}
